package edu.spbsu.nonsm00th.qdiff.parser.word;

/**
 * Enum of all possible control elements.
 *
 * @author mbuzdov
 */
public enum Control implements Word {

    OPEN_BRACKET("({["),
    CLOSE_BRACKET(")}]"),
    SEPARATOR(",;");

    public static String ALPHABET;
    static {
        StringBuilder builder = new StringBuilder();
        for (Control controlEnum : Control.values()) {
            builder.append(controlEnum.value);
        }
        ALPHABET = builder.toString();
    }

    private String value;

    private Control(String value) {
        this.value = value;
    }

    public static Control getControlElement(String value) {
        for (Control celement : values()) {
            if (celement.value.contains(value)) {
                return celement;
            }
        }
        return null;
    }
}
